package cn.com.nes.site.action.monitor;

import cn.com.nes.common.util.DBUtils;
import cn.com.nes.site.entity.DataRes;
import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.module.service.monitor.EquipmentInfoService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller("installInfo")
@RequestMapping("/installInfo")
public class InstallInfoController {

    @Resource
    EquipmentInfoService equipmentInfoService;

    @RequestMapping(method = RequestMethod.POST, value = "/editInstallInfo")
    public @ResponseBody
    PageData editInstallInfo(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws Exception {
        DataRes reqStatus = DBUtils.setRemoteVisit(request, response, true);
        PageData res;
        if (reqStatus.getRetCode() != 0) {
            res = new PageData();
            res.setRetCode(reqStatus.getRetCode());
            res.setRetMessage(reqStatus.getRetMessage());
            return res;
        }
        res = equipmentInfoService.editInstallInfo(reqStatus.getReq());
        return res;
    }

}
